package com.manage.competition.common;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * Create with IDEA
 *
 * @Author:Vantcy
 * @Date: Create in 17:13 2019/1/23
 * @Description:
 */
public class Const {
    public static final String TOKEN_USER = "Token";

    public static final String SESSION_USER = "Session";

    /**
     * session 过期时间一小时
     */
    public static final long USER_SESSION_EXPIRE_TIME = 60*60;

    public interface ProductListOrderBy{
        Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_desc","price_asc");
    }

    public interface Sex{
        /**
         * 男，女，未知
         */
        int MAN = 1;
        int FEMAL = 2;
    }
    public interface Status{
        /**
         * 启用
         * 禁用
         * 非法
         */
        int ENABLE = 1;
        int DISABLE = 2;
        int ILLEGAL = 3;
    }
    public interface Cart{
        /**
         * 购物车选中
         * 未选中
         */
        int CHECKED = 1;
        int UN_CHECKED = 0;

        String LIMIT_NUM_FAIL = "LIMIT_NUM_FAAIL";
        String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
    }
    public interface Role{
        /**
         * 普通用户
         * 管理员
         */
        int ROLE_CUSTOMER = 0;
        int ROLE_ADMIN = 1;

    }
    public enum ProductStatusEnum{
        /**
         *
         */
        ON_SALE(1,"在线");
        private String value;
        private int code;

        ProductStatusEnum(int code, String value) {
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }
    public enum OrderStatusEnum{
        /**
         *
         *
         */
        CANCELED(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAID(20,"已支付"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");

        OrderStatusEnum(int code ,String value) {
            this.value = value;
            this.code = code;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static OrderStatusEnum codeOf(int code){
            for(OrderStatusEnum orderStatusEnum : values()){
                if (orderStatusEnum.getCode()==code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }
    public interface AlipayCallback{
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILED = "failed";
    }

    public enum PayPlatformEnum{
        /**
         *
         */
        ALIPAY(1,"支付宝");

        PayPlatformEnum(int code,String value) {
            this.value = value;
            this.code = code;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }

    public enum PaymentTypeEnum{
        /**
         *
         */
        ONLINE_PAY(1,"在线支付");

        PaymentTypeEnum(int code,String value) {
            this.value = value;
            this.code = code;
        }
        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static PaymentTypeEnum codeOf(int code){
            for(PaymentTypeEnum paymentTypeEnum : values()){
                if (paymentTypeEnum.getCode()==code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }
    }
}
